//=============================
// Neo Dark Ages
//=============================

#include "../game/bg_public.h"
#include "../NDA_Server/BG_Header.h"

int get_class_data ( playerState_t * ps, int data_type )
{
	switch ( data_type )
	{
	case CLASSDATA_FLAGS:
		return ((ps->ndaClassData >> CLASSDATA_FLAGS_OFFSET) & ((2 ^ CLASSDATA_FLAGS_BITS) - 1));

	case CLASSDATA_ELEMENT:
		return ((ps->ndaClassData >> CLASSDATA_ELEMENT_OFFSET) & ((2 ^ CLASSDATA_ELEMENT_BITS) - 1));

	case CLASSDATA_TYPE:
	default:
		return (ps->ndaClassData & ((2 ^ CLASSDATA_TYPE_BITS) - 1));
	}

	return 0;
}

void set_class_data ( playerState_t * ps, int data_type, int data )
{
	switch ( data_type )
	{
	case CLASSDATA_TYPE:
		ps->ndaClassData |= (data & ((2 ^ CLASSDATA_TYPE_BITS) - 1));
		break;

	case CLASSDATA_FLAGS:
		ps->ndaClassData |= ((data & ((2 ^ CLASSDATA_FLAGS_BITS) - 1)) << CLASSDATA_FLAGS_OFFSET);
		break;

	case CLASSDATA_ELEMENT:
		ps->ndaClassData |= ((data & ((2 ^ CLASSDATA_ELEMENT_BITS) - 1)) << CLASSDATA_ELEMENT_OFFSET);
		break;
	}

	return;
}

// eof
